<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2011 Alex Paréj.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:composite="http://java.sun.com/jsf/composite"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:p="http://primefaces.org/ui" > 
    <composite:interface>
        <composite:attribute name="id"/>
        <composite:attribute name="header" required="true"/>
        <composite:attribute name="message" required="true"/>
        <composite:attribute name="widgetVar" required="true"/>
        <composite:attribute name="yesLabel" default="#{msg.yes}"/>
        <composite:attribute name="noLabel" default="#{msg.no}"/>
        <composite:attribute name="update" default="@this"/>
        <composite:attribute name="icon" default="trash"/>
        <composite:attribute name="deleteAction" required="true"
                             method-signature="void actionListener()"/>
        <composite:facet name="content"/>
    </composite:interface>

    <composite:implementation>
        <p:confirmDialog id="#{cc.attrs.widgetVar}" header="#{cc.attrs.header}" 
                         message="#{cc.attrs.message}"
                         severity="#{cc.attrs.icon}"
                         widgetVar="#{cc.attrs.widgetVar}">
            <h:form id="#{cc.attrs.widgetVar}Form">
                <composite:renderFacet name="content"/>
                <div style="text-align: center">
                    <p:commandButton icon="ui-icon-check" value="#{msg.yes}" 
                                     actionListener="#{cc.attrs.deleteAction}"
                                     update="#{cc.attrs.update}"
                                     oncomplete="#{cc.attrs.widgetVar}.hide();"/>
                    <p:commandButton icon="ui-icon-cancel" value="#{msg.no}"
                                     onclick="#{cc.attrs.widgetVar}.hide();return false;"/>
                </div>
            </h:form>
        </p:confirmDialog>
    </composite:implementation>
</ui:component>
